package optimizations.lexer;

%%

%class BrainfuckLexer
%type Token

%line
%column

%{
  public static final String DEFAULT_UNIT = "unknown unit"; 
  private String unit = DEFAULT_UNIT;

  public BrainfuckLexer(java.io.Reader reader, String unit) {
  	this(reader);
  	this.unit = unit;
  } 

  Token token(TokenType type) {
    return new Token(type, yytext(), yyline + 1, yycolumn + 1, unit);
  }

  public boolean hasReadEOF() {
    return zzAtEOF;
  } 
%}

%%

<YYINITIAL> {
  "<" { return token(TokenType.LESS_THAN); }
  ">" { return token(TokenType.GREATER_THAN); }
  "." { return token(TokenType.PERIOD); }
  "," { return token(TokenType.COMMA); }
  "-" { return token(TokenType.MINUS); }
  "+" { return token(TokenType.PLUS); }
  "[" { return token(TokenType.LEFT_BRACKET); }
  "]" { return token(TokenType.RIGHT_BRACKET); }
}
